import {MyNavBar, ShowLoading} from '@/components'
import {useListHook} from '@/hooks'
import {_getLease} from './store'
import {history} from 'umi'
import LeaseItem from './components/leaseItem'
import './index.less'

function Lease() {
  const {data, showLoading} = useListHook({func: _getLease})

  return (
    <div>
      <MyNavBar title='我的租约'/>
      <div className='lease'>
        {data?.length ? data.map(item => (
          <LeaseItem key={item?.id} handleClick={(id) => {
            history.push({pathname: '/user/leaseDetail', query: {id}})
          }} data={item}/>
        )) : ''}
        <ShowLoading showLoading={showLoading}/>
      </div>
    </div>
  )
}

export default Lease
